package com.hlf.modules.sys.service.impl;

import com.hlf.modules.sys.entity.SysUserTokenEntity;
import com.hlf.modules.sys.mapper.SysMenuMapper;
import com.hlf.modules.sys.mapper.SysUserTokenMapper;
import com.hlf.modules.sys.service.ShiroService;
import com.hlf.modules.wechat.mapper.CustomerMapper;
import com.hlf.modules.wechat.model.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

@Service
public class ShiroServiceImpl implements ShiroService {
    @Autowired
    private SysMenuMapper sysMenuMapper;
    @Autowired
    private SysUserTokenMapper sysUserTokenMapper;
    @Autowired
    private CustomerMapper customerMapper;

    @Override
    public Set<String> getUserPermissions(long userId) {
//        List<String> permsList;
//
//        //系统管理员，拥有最高权限
//        if(userId == Constant.SUPER_ADMIN){
//            List<SysMenuEntity> menuList = sysMenuMapper.queryList(new HashMap<>());
//            permsList = new ArrayList<>(menuList.size());
//            for(SysMenuEntity menu : menuList){
//                permsList.add(menu.getPerms());
//            }
//        }else{
//            permsList = sysUserMapper.queryAllPerms(userId);
//        }
//        //用户权限列表
//        Set<String> permsSet = new HashSet<>();
//        for(String perms : permsList){
//            if(StringUtils.isBlank(perms)){
//                continue;
//            }
//            permsSet.addAll(Arrays.asList(perms.trim().split(",")));
//        }
        return null;
    }

    @Override
    public SysUserTokenEntity queryByToken(String token) {
        return sysUserTokenMapper.queryByToken(token);
    }

    @Override
    public Customer queryUser(Long customerId) {
        return customerMapper.selectByPrimaryKey(customerId);
    }
}
